
// William R. Doyle
// 2009
// Replication file for paper:
  
// Doyle, W. R. (2010). Does state merit-based aid “crowd out” need based aid?
//    Research in Higher Education, 51(5):397–415


// Required non-core packages:
// xtabond2 (http://fmwww.bc.edu/RePEc/bocode/x)
// collin (http://www.ats.ucla.edu/stat/stata/ado/analysis/)
// estout (http://repec.org/bocode/e/estout)

use meritneed, clear

gen ln_need_fte= log(need_fte+10)

gen ln_merit_fte= log(merit_fte+10)

gen percpriv4= priv4/(pub2+pub4+priv4)

gen legideo_t=legideo/100

gen taxcpc_t=taxcpc/100

gen pub4tuit_t=pub4tuit/1000


local controls l.legideo_t l.percpriv4 l.taxcpc_t l.pub4tuit_t

tsset statenum year

// OLS

quietly: xi: reg ln_need_fte l.ln_need_fte l.ln_merit_fte i.year, ///
  robust cluster (statenum)

estimates store ols_basic


quietly: xi: reg ln_need_fte l.ln_need_fte l.ln_merit_fte `controls' i.year, ///
  robust cluster (statenum)

estimates store ols_full


// Fixed Effects 

quietly: xi: xtreg ln_need_fte l.ln_need_fte l.ln_merit_fte i.year, ///
  fe robust cluster (statenum)

estimates store fe_basic


quietly: xi: xtreg ln_need_fte l.ln_need_fte l.ln_merit_fte `controls' i.year, ///
  fe robust cluster (statenum)

estimates store fe_full

 
quietly: xi:xtabond2 ln_need_fte l.ln_need_fte l.ln_merit_fte i.year, ///
  iv(l.ln_need_fte i.year, eq(lev))

estimates store iv_basic


quietly: xi:xtabond2 ln_need_fte l.ln_need_fte l.ln_merit_fte `controls' i.year, ///
  iv(l.ln_need_fte `controls' i.year, eq(lev))

estimates store iv_full


quietly: xi: xtabond2 ln_need_fte l.ln_need_fte l.ln_merit_fte i.year, ///
  gmm(l.ln_need_fte l.ln_merit_fte, lag(2 .)) iv(`controls' i.year) ///
  noleveleq two

estimates store ab2lag_basic


quietly: xi: xtabond2 ln_need_fte l.ln_need_fte l.ln_merit_fte `controls' i.year, ///
  gmm(l.ln_need_fte l.ln_merit_fte, lag(2 .)) iv(`controls' i.year) ///
  noleveleq two robust

estimates store ab2lag_full


quietly: xi: xtabond2 ln_need_fte l.ln_need_fte l.ln_merit_fte i.year, ///
  gmm(l.ln_need_fte l.ln_merit_fte, lag(3 .)) iv(`controls' i.year) ///
  noleveleq two robust artests(4)

estimates store ab3lag_basic


quietly: xi: xtabond2 ln_need_fte l.ln_need_fte l.ln_merit_fte `controls' i.year, ///
  gmm(l.ln_need_fte l.ln_merit_fte, lag(3 .)) iv( i.year) ///
  noleveleq two artests(4) robust 

estimates store ab3lag_full


/* Collinearity Diagnostics */

gen mydneed_fte=d.ln_need_fte

gen mydmerit_fte=d.ln_merit_fte

gen mydlegideo=d.l.legideo

gen mydpercpriv4=d.l.percpriv4

gen mydtaxcpc=d.l.taxcpc_t

gen mydpub4tuit=d.l.pub4tuit_t

collin ln_need_fte ln_merit_fte legideo percpriv4 taxcpc pub4tuit _Iyear_1986-_Iyear_2004

collin mydneed_fte mydmerit_fte mydlegideo mydpercpriv4 mydtaxcpc mydpub4tuit _Iyear_1986-_Iyear_2004

// Report Results

/* Numbers only (to put into existing LaTeX document) */
  
#delimit;

estout
      ols_basic
      ols_full
      fe_basic
      fe_full
      iv_basic
      iv_full
      ab2lag_basic
      ab2lag_full
      ab3lag_basic
      ab3lag_full
using "merit_need_mod-loggeds.tex" ,
style(tex) cells(b(fmt(%9.3f)) se(par fmt(%9.3f)) )
stats (N sargan sar_df sarganp ar2 ar2p ar3 ar3p chi2 chi2p,
       fmt(%9.0f %9.2f %9.0f %9.2f)
       )
drop (_I*) replace  ;

/* Table with complete LaTeX headers/footer for quick viewing/printing */

esttab
      ols_basic
      ols_full
      fe_basic
      fe_full
      iv_basic
      iv_full
      ab2lag_basic
      ab2lag_full
      ab3lag_basic
      ab3lag_full 
using "merit_need_mod-loggeds_printable.tex",
b(%9.3f)
se(%9.3f)
stats (N sargan sar_df sarganp ar2 ar2p ar3 ar3p chi2 chi2p,
       fmt(%9.0f %9.2f %9.0f %9.2f))
not
booktabs
mtitles
preh(\documentclass{article}
     \usepackage{booktabs}
     \usepackage[landscape,margin=.75in]{geometry}
     \begin{document}
     \def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
     \begin{tabular*}{\linewidth}{@{\hskip\tabcolsep\extracolsep\fill}l*{10}{c}}
     \toprule)
postf(\bottomrule
      \multicolumn{11}{l}{\footnotesize Standard errors in parentheses}\\
      \multicolumn{11}{l}{\footnotesize \sym{*} \(p<0.05\), \sym{**} \(p<0.01\), \sym{***} \(p<0.001\)}\\
      \end{tabular*}
      \end{document})
compress
drop (_I*) replace  ; 

#delimit cr

